//
//  Mark.m
//  test
//
//  Created by Christian Speich on 11.01.08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "Mark.h"


@implementation Mark

- (int) mark
{
	return mark;
}

- (void) setMark:(int)mark_
{
	mark = mark_;
}

- (float) valency
{
	return valency;
}

- (void) setValency:(float)valency_
{
	valency = valency_;
}

- (NSString*) type
{
	return [type copy];
}

- (void) setType:(NSString*)type_
{
	if (type)
		[type release];
	
	type = [type_ copy];
}

- (NSString*)xml
{
	return [self xmlWithOffset:0];
}

- (NSString*)xmlWithOffset:(int)i
{
	NSMutableString* xml = [[NSMutableString alloc] initWithCapacity:50];
	NSMutableString* offset = [[NSMutableString alloc] initWithCapacity:i];
	int y;
	
	for (y = 0; y < i; y++) {
		[offset appendString:@" "];
	}
	
	if ([type isEqualToString:@"classTest"]) {
		[xml appendFormat:@"%@<mark type=\"%@\" valency=\"%1.2f\">%i</mark>\n", offset, type, valency, mark];
	}
	else {
		[xml appendFormat:@"%@<mark type=\"%@\">%i</mark>\n", offset, type, mark];
	}
	
	[offset release];
	
	return xml;
}

- (void) dealloc
{
	[type release];
	
	[super dealloc];
}


@end
